Mathspp Blog

code review — Articles where we explore the elegance of a piece of code

The function random.shuffle relies on the mutability of the argument and mutability is a pain in the arse, so we propose an alternative.

In this article I explore a common code smell related to conditionals and Boolean values and show how to fix it.

This article explains why a user would need to use enums in their code and shows how to do it with a simple example.

This article shows 5 ways of flattening a list of lists, ranked from worst to best.

In this article we reimplement the built-in enumerate in the best way possible.

The Zen of Python says “there should be one -- and preferably only one -- obvious way to do it”, but what if there's a dozen obvious ways to do it?